// import Home from '@/Pages/Home'
// const Home = () => import("../Pages/Home")

function lazy(comp) {
    return () => import(`../` + comp)
}
export default [
    {
        path: '/home',
        name: 'home',
        component: lazy("Pages/Home"),
    },
    {
        path: '/login',
        name: 'login',
        component: lazy("Pages/Login"),
        meta: {
            ishidden: true
        }
    },
    {
        path: '/register',
        name: 'register',
        component: lazy("Pages/Register"),
        meta: {
            ishidden: true
        }
    },
    {
        path: '/search/:keyword?',
        name: 'search',
        component: lazy("Pages/Search"),
    },
    {
        path: '/detail/:skuid?',
        name: 'detail',
        component: lazy("Pages/Detail"),
    },
    {
        path: '/addCartSuccess',
        name: 'addCartSuccess',
        component: lazy("Pages/AddCartSuccess"),
        beforeEnter: (to, from, next) => {
            if (from.nam === 'detail') {
                next()
            } else {
                next('/search')
            }
        }
    },
    {
        path: '/shopCart',
        name: 'shopCart',
        component: lazy("Pages/ShopCart"),
    },
    {
        path: '/trade',
        name: 'trade',
        component: lazy('Pages/Trade'),
        beforeEnter: (to, from, next) => {
            if (from.nam === 'shopCart') {
                next()
            } else {
                next('/shopCart')
            }
        }
    },
    {
        path: '/pay',
        name: 'pay',
        component: lazy('Pages/Pay'),
        beforeEnter: (to, from, next) => {
            if (from.nam === 'trade') {
                next()
            } else {
                next('/shopCart')
            }
        }
    },
    {
        path: '/paySuccess',
        name: 'paySuccess',
        component: lazy('Pages/PaySuccess'),
        beforeEnter: (to, from, next) => {
            if (from.nam === 'pay') {
                next()
            } else {
                next('/shopCart')
            }
        }
    },
    {
        path: '/center',
        name: 'center',
        component: lazy('Pages/Center'),
        redirect: '/center/myorder',
        children: [
            {
                path: '/center/myorder',
                name: 'myorder',
                component: lazy('Pages/Center/components/Myorder'),
            },
            {
                path: '/center/otherOrder',
                name: 'otherOrder',
                component: lazy('Pages/Center/components/OtherOrder'),
            },
        ]
    },

]